<template>
    <div style="margin-top: -25px;">
        <Table
            ref="table"
            :columns="columns"
            :data="features"
            class="ivu-mt">
            <template slot-scope="{ row, index }" slot="fieldName">
                <Input v-if="drawer.type !== 'read'" type="text" maxlength="64" v-model="features[index].fieldName">
                    <template #prefix>
                       <p style="margin-top: 8px;margin-right:-15px;">{{ prefix }}</p>
                    </template>
                </Input>
                <span v-else>{{ features[index].fieldName }}</span>
            </template>
            <template slot-scope="{ row, index }" slot="defaultValue">
                <Input type="text" v-model="features[index].defaultValue" v-if="drawer.type !== 'read'" />
                <span v-else>{{ features[index].defaultValue }}</span>
            </template>
            <template slot-scope="{ row, index }" slot="comments" >
                <Input type="text" v-model="features[index].comments" v-if="drawer.type !== 'read'"/>
                <span v-else>{{ features[index].comments }}</span>
            </template>
        </Table>
       <div style="margin-top: 5px"><Button class="ivu-ml-8" @click="handleReset">{{lang.reset}}</Button></div>
    </div>
</template>

<script>
export default {
    name: "cfg-model-features-edit",
    data() {
        return {
            currentId: '',
            currentScore: '',
        }
    },
    props: {
        drawer: {
            default: () => {
                return {
                    show: false,
                    type: 'edit', // edit || read || new
                };
            }
        },
        features:{
            default: () => {
                return {}
            }
        },
        prefix:{
            default: () => {
                return "sf_";
            }
        }
    },
    computed: {
        lang() {
            return {
                "en-US": {
                    propertyName: 'propertyName',
                    defaultValue: 'defaultValue',
                    comments: 'comments',
                    reset:'Reset'
                },
                "zh-CN": {
                    propertyName: '属性名称',
                    defaultValue: '默认值',
                    comments: '说明',
                    reset:'重置'
                },
            }[this.G_Locale]
        },
        columns(){
            return [
                {
                    key: 'propertyName',
                    title: this.lang.propertyName,
                    minWidth: 100,
                    align: 'center',
                    show: true,
                    slot: "fieldName"
                },
                {
                    key: 'defaultValue',
                    title: this.lang.defaultValue,
                    minWidth: 100,
                    align: 'center',
                    show: true,
                    slot: "defaultValue"
                },
                {
                    key: 'comments',
                    title: this.lang.comments,
                    minWidth: 100,
                    align: 'center',
                    show: true,
                    slot: "comments"
                }
            ]
        }
    },
    methods:{
        handleReset(){
            this.$emit('resetFeatures',this.prefix);
        }
    }
}
</script>
